import React from 'react';
import { getCookie, removeCookie } from '@/utils/cookie';
import { Button } from 'antd'
import { history, connect, ILoginState } from 'umi'
export interface IRightHeaderProps {
  adminname?: string
}

// export function RightHeader (props: IRightHeaderProps) {
//   return (
//     <div>
//       您当前登录的账户为：{
//         getCookie('adminname')
//       }
//       <Button type="ghost" danger onClick = { () => {
//         removeCookie('loginState')
//         removeCookie('adminname')
//         removeCookie('role')
//         removeCookie('token')
//         history.push('/login')
//       }}>退出</Button>
//     </div>
//   );
// }
const RightHeader =  (props: IRightHeaderProps) => {
  return (
    <div>
      您当前登录的账户为：{
        props.adminname
      }
      <Button type="ghost" danger onClick = { () => {
        removeCookie('loginState')
        removeCookie('adminname')
        removeCookie('role')
        removeCookie('token')
        history.push('/login')
      }}>退出</Button>
    </div>
  );
}

export default connect(state => {
  return {
    adminname: state.login.adminname
  }
})(RightHeader)
